﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HPortal.Lib;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;

namespace HPortal
{
    public partial class Panel : PanelControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable pn = DatabaseHelper.Select("exec getPanel " + PanelID.ToString());
            if (pn.Rows.Count > 0)
            {
                this.CellTopPanel.Visible = (Boolean)pn.Rows[0]["DisplayContainer"];
                this.CellTopPanel.Cells[0].InnerHtml = pn.Rows[0]["Header"].ToString();
                this.CellContentPanel.Controls.Add(LoadPanel(int.Parse(pn.Rows[0]["PanelID"].ToString()), pn.Rows[0]["SourceFile"].ToString(), pn.Rows[0]["Field1"].ToString(), pn.Rows[0]["Field2"].ToString()));
            }
        }
        public PanelControl LoadPanel(int panelID, string src,string field1, string field2)
        {
            PanelControl pc = (PanelControl)LoadControl(src);
            pc.PanelID = panelID;
            pc.field1 = field1;
            pc.field2 = field2;
            return pc;
        }
    }
}